﻿using System;
using System.Linq.Expressions;
using SBACN.WebSite.Code;
using SBACN.WebSite.Models;

namespace SBACN.WebSite
{
    public partial class MediaShow : MemberBasePage
    {
		protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }

        public string GetURL
        {
            get
            { 
                string t = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(t))
                {
                    int id = int.Parse(t);
                    Expression<Func<TB_MediaReports, bool>> f = (p => p.ID == id);
                    var result = DAL.DALHelper.Instance.GetFirstOrDefaultObject<TB_MediaReports>(f);
                    if (result != null)
                    {
                        return result.SourceURL;
                    }
                } 
                return "";
            }
        }

        private void BindData()
        {
            string t = Request.QueryString["id"];
            if (!string.IsNullOrEmpty(t))
            {
                int id = int.Parse(t);
                Expression<Func<TB_MediaReports, bool>> f = (p => p.ID == id);
                var result = DAL.DALHelper.Instance.GetFirstOrDefaultObject<TB_MediaReports>(f);
                if (result != null)
                {
                    lblTitle.Text = result.Title;
					lblData.Text = result.ReportDate.ToString("yyyy-MM-dd");
                    lblContent.Text = result.Description;
					
					//if (string.IsNullOrEmpty(result.SnapPic))
					//    imgMedia.Visible = false;
					//else
					//{
					//    imgMedia.Visible = true;
					//    imgMedia.ImageUrl = result.SnapPic;
					//}//hylDown.NavigateUrl = result.AttachmentsJosnUrl; 
                }

            }
        }
    }
}